/**
 * @author : Bruce
 * @date: 2024/7/16 - 07 - 16 - 15:44
 * @Description: PACKAGE_NAME
 * @version: 1.0
 */
public class Student {
    public Student(String name, int age, String sex) {
        try {
            this.setSex(sex);
        } catch (IllegalArgumentException e) {
            e.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        }
        this.age = age;
        this.name = name;
    }

    private String name;
    private int age;
    private String sex;

    public Student() {
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", sex='" + sex + '\'' +
                '}';
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) throws Exception {
        if (sex.equals("男") || sex.equals("女")) {
            this.sex = sex;
        } else {
//            throw new RuntimeException("性别不对");
//            try {
//                throw new Exception();
//            } catch (Exception e) {
//                e.printStackTrace();
//            }
            throw new Exception();
        }
    }

    public static void main(String[] args) {
        Student student = new Student("杨子豪", 10, "1");
    }
}
